<template>
  <el-form :model="UserInfo" label-width="100px">
  <el-form-item label="账号：" prop="UserID">
    <el-input v-model="UserInfo.UserID" disabled />
  </el-form-item>
  <el-form-item label="状态：" prop="UserStatus">
    <el-select v-model="UserInfo.UserStatus" placeholder="请选择状态" style="width: 100%">
      <el-option label="正常" value="0" />
      <el-option label="暂停" value="3" />
      <el-option label="注销" value="9" />
    </el-select>
  </el-form-item>
  <el-form-item>
    <el-button @click="submit(UserInfo)" type="primary">确定</el-button>
    <el-button @click="cancel()">取消</el-button>
  </el-form-item>
</el-form>
</template>
<script lang="ts" setup>

import { httpReqeustApi } from '/@/api/linxyun/base';
import { ElMessage, ElMessageBox } from 'element-plus';

const emit = defineEmits(["closePop","refresh"])
const httpReqeust = httpReqeustApi();
const props = defineProps<{UserInfo:Record<string, any>}>();
const { UserInfo } = toRefs(props);
 

/**
 * @description: 提交
 */
const submit = (param:any) =>{ 
  const finallyParam ={
    UserID:param.UserID,
    UserStatus:param.UserStatus
  }
  httpReqeust.Post('updateUserRole',finallyParam).then((result:any) => {
    if(result.code="0000"&&result.msg=="success"){
      ElMessage({
		    type: 'success',
			  message: '修改成功',
		  });
    }else{
      ElMessage({
		    type: 'error',
			  message: '修改失败',
		  });
    }
    cancel()
    emit('refresh')
  }).catch((err) => {
    ElMessage({
		  type: 'error',
			message: '修改失败',
		});
  });
}
/**
 * @description: 取消
 */
const cancel = () =>{
  emit('closePop',false)
}
</script>